

import time

print("\n如果是实验1,2,3,4 内核为正点原子出厂系统,led控制应用接口：")
LED_TRIGGER =   "/sys/class/leds/sys-led/trigger"
LED_BRIGHTNESS =  "/sys/class/leds/sys-led/brightness"

print(LED_TRIGGER)
print(LED_BRIGHTNESS)


print("\n如果是实验5 内核为正点原子的开发版本,led控制应用接口：")
LED_TRIGGER =   "/sys/class/leds/red/trigger"
LED_BRIGHTNESS =  "/sys/class/leds/red/brightness"

print(LED_TRIGGER)
print(LED_BRIGHTNESS)

#####################################################################
fd1 = open(LED_TRIGGER,mode='r');
modes = fd1.read()
print("\nled trigger的模式为:",modes)
fd1.close()

#####################################################################
fd1 = open(LED_TRIGGER,mode='w');
fd2 = open(LED_BRIGHTNESS, mode='w');

fd1.write("none"); 	#先将触发模式设置为none
fd2.write("1"); 	#点亮LED
fd1.flush()
fd2.flush()
time.sleep(1)




cmd="timer"
fd1.write(cmd); 	#先将触发模式设置为timer
fd1.flush()
time.sleep(1)

cmd="heartbeat"
fd1.write(cmd)#先将触发模式设置为heartbeat
fd1.flush()
time.sleep(1)


fd1.write("none"); 	#先将触发模式设置为none
fd2.write("0"); 	#灭LED
fd1.flush()
fd2.flush()
time.sleep(5)

fd1.close()
fd2.close()
